package com.weimei.conversionTreasure.weight;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.activity.AddJxsActivity;
import com.weimei.conversionTreasure.activity.AddKhActivity;
import com.weimei.conversionTreasure.utils.ValidateUtils;

public class BottomAddPop extends BottomPopupView {

    private TextView xl,cc;
    private ImageView cancel;
    private Context mContext;

    private Click mClick;

    public interface Click{
        void click(String s,String records,String type);
    }


    public BottomAddPop(@NonNull Context context, Click click) {
        super(context);
        this.mContext = context;
        this.mClick = click;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.layout_bottom_add;
    }

    @Override
    protected void onCreate() {
        cancel = findViewById(R.id.cancel);
        xl = findViewById(R.id.xl);
        cc = findViewById(R.id.cc);

        cancel.setOnClickListener(view -> dismiss());
        cc.setOnClickListener(view ->
                new XPopup.Builder(mContext)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)//如果不加这个，评论弹窗会移动到软键盘上面
                .enableDrag(false)
                .asCustom(new BottomAddRecordPop(mContext, (s, records) -> {
                    if (ValidateUtils.isNotEmptyString(s)){
                        mClick.click(s,records,"0");
                        dismiss();
                    }
                }))
                .show()
        );

        xl.setOnClickListener(view -> new XPopup.Builder(mContext)
                .dismissOnTouchOutside(false)
                .moveUpToKeyboard(false)//如果不加这个，评论弹窗会移动到软键盘上面
                .enableDrag(false)
                .asCustom(new BottomAddRecordPop(mContext, (s, records) -> {
                    if (ValidateUtils.isNotEmptyString(s)){
                        mClick.click(s,records,"1");
                        dismiss();
                    }
                }))
                .show());

    }



}
